package com.gan.springcloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableDiscoveryClient
public class CartConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(CartConsumerApplication.class, args);
    }

    /**
     * 创建服务调用的对象
     *
     * @return
     * @LoadBalanced 添加此注解后，RestTemplate就具有了ribben客户端负载均衡能力
     */
    @Bean
    @LoadBalanced//负载均衡客户端
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
